﻿namespace AutoRevit.Event;

/// <summary>
/// revit外部事件处理扩展函数
/// </summary>
public static class ExternalHandlerLiteExtensions
{
    /// <summary>
    /// 执行外部事件
    /// </summary>
    /// <param name="ehl"></param>
    /// <param name="action"></param>
    public static void Execute(this IExtensionsExternalEventHandler ehl,
                               Action action)
    {
        var actionHandler = new ExternalEventHandlerInfo(action);
        ehl.Execute(actionHandler);
    }

    /// <summary>
    /// 执行外部事件
    /// </summary>
    /// <typeparam name="T1"></typeparam>
    /// <param name="ehl"></param>
    /// <param name="param1"></param>
    /// <param name="action"></param>
    public static void Execute<T1>(this IExtensionsExternalEventHandler ehl,
                                   T1 param1,
                                   Action<UIApplication, T1> action)
    {
        var actionHandler = new ExternalEventHandlerInfo(action, param1);
        ehl.Execute(actionHandler);
    }

    /// <summary>
    /// 执行外部事件
    /// </summary>
    /// <typeparam name="T1"></typeparam>
    /// <typeparam name="T2"></typeparam>
    /// <param name="ehl"></param>
    /// <param name="param1"></param>
    /// <param name="param2"></param>
    /// <param name="action"></param>
    public static void Execute<T1, T2>(this IExtensionsExternalEventHandler ehl,
                                       T1 param1,
                                       T2 param2,
                                       Action<UIApplication, T1, T2> action)
    {
        var actionHandler = new ExternalEventHandlerInfo(action, param1, param2);
        ehl.Execute(actionHandler);
    }

    /// <summary>
    /// 执行外部事件
    /// </summary>
    /// <typeparam name="T1"></typeparam>
    /// <typeparam name="T2"></typeparam>
    /// <typeparam name="T3"></typeparam>
    /// <param name="ehl"></param>
    /// <param name="param1"></param>
    /// <param name="param2"></param>
    /// <param name="param3"></param>
    /// <param name="action"></param>
    public static void Execute<T1, T2, T3>(this IExtensionsExternalEventHandler ehl,
                                           T1 param1,
                                           T2 param2,
                                           T3 param3,
                                           Action<UIApplication, T1, T2, T3> action)
    {
        var actionHandler = new ExternalEventHandlerInfo(action, param1, param2, param3);
        ehl.Execute(actionHandler);
    }

    /// <summary>
    /// 执行外部事件
    /// </summary>
    /// <typeparam name="T1"></typeparam>
    /// <typeparam name="T2"></typeparam>
    /// <typeparam name="T3"></typeparam>
    /// <typeparam name="T4"></typeparam>
    /// <param name="ehl"></param>
    /// <param name="param1"></param>
    /// <param name="param2"></param>
    /// <param name="param3"></param>
    /// <param name="param4"></param>
    /// <param name="action"></param>
    public static void Execute<T1, T2, T3, T4>(this IExtensionsExternalEventHandler ehl,
                                               T1 param1,
                                               T2 param2,
                                               T3 param3,
                                               T4 param4,
                                               Action<UIApplication, T1, T2, T3, T4> action)
    {
        var actionHandler = new ExternalEventHandlerInfo(action, param1, param2, param3, param4);
        ehl.Execute(actionHandler);
    }

    /// <summary>
    /// 执行外部事件
    /// </summary>
    /// <typeparam name="T1"></typeparam>
    /// <typeparam name="T2"></typeparam>
    /// <typeparam name="T3"></typeparam>
    /// <typeparam name="T4"></typeparam>
    /// <typeparam name="T5"></typeparam>
    /// <param name="ehl"></param>
    /// <param name="param1"></param>
    /// <param name="param2"></param>
    /// <param name="param3"></param>
    /// <param name="param4"></param>
    /// <param name="param5"></param>
    /// <param name="action"></param>
    public static void Execute<T1, T2, T3, T4, T5>(this IExtensionsExternalEventHandler ehl,
                                                   T1 param1,
                                                   T2 param2,
                                                   T3 param3,
                                                   T4 param4,
                                                   T5 param5,
                                                   Action<UIApplication, T1, T2, T3, T4, T5> action)
    {
        var actionHandler = new ExternalEventHandlerInfo(action, param1, param2, param3, param4, param5);
        ehl.Execute(actionHandler);
    }

    /// <summary>
    /// 执行外部事件
    /// </summary>
    /// <typeparam name="T1"></typeparam>
    /// <typeparam name="T2"></typeparam>
    /// <typeparam name="T3"></typeparam>
    /// <typeparam name="T4"></typeparam>
    /// <typeparam name="T5"></typeparam>
    /// <typeparam name="T6"></typeparam>
    /// <param name="ehl"></param>
    /// <param name="param1"></param>
    /// <param name="param2"></param>
    /// <param name="param3"></param>
    /// <param name="param4"></param>
    /// <param name="param5"></param>
    /// <param name="param6"></param>
    /// <param name="action"></param>
    public static void Execute<T1, T2, T3, T4, T5, T6>(this IExtensionsExternalEventHandler ehl,
                                                       T1 param1,
                                                       T2 param2,
                                                       T3 param3,
                                                       T4 param4,
                                                       T5 param5,
                                                       T6 param6,
                                                       Action<UIApplication, T1, T2, T3, T4, T5, T6> action)
    {
        var actionHandler = new ExternalEventHandlerInfo(action, param1, param2, param3, param4, param5, param6);
        ehl.Execute(actionHandler);
    }

    /// <summary>
    /// 执行外部事件
    /// </summary>
    /// <typeparam name="T1"></typeparam>
    /// <typeparam name="T2"></typeparam>
    /// <typeparam name="T3"></typeparam>
    /// <typeparam name="T4"></typeparam>
    /// <typeparam name="T5"></typeparam>
    /// <typeparam name="T6"></typeparam>
    /// <typeparam name="T7"></typeparam>
    /// <param name="ehl"></param>
    /// <param name="param1"></param>
    /// <param name="param2"></param>
    /// <param name="param3"></param>
    /// <param name="param4"></param>
    /// <param name="param5"></param>
    /// <param name="param6"></param>
    /// <param name="param7"></param>
    /// <param name="action"></param>
    public static void Execute<T1, T2, T3, T4, T5, T6, T7>(this IExtensionsExternalEventHandler ehl,
                                                           T1 param1,
                                                           T2 param2,
                                                           T3 param3,
                                                           T4 param4,
                                                           T5 param5,
                                                           T6 param6,
                                                           T7 param7,
                                                           Action<UIApplication, T1, T2, T3, T4, T5, T6, T7> action)
    {
        var actionHandler = new ExternalEventHandlerInfo(action, param1, param2, param3, param4, param5, param6, param7);
        ehl.Execute(actionHandler);
    }
}
